only try to strcmp or strlen if we managed to normalize and casefold the
authorKristian Rietveld <kris@gtk.org>
Wed, 17 Dec 2003 22:33:54 +0000 (22:33 +0000)
committerKristian Rietveld <kristian@src.gnome.org>
Wed, 17 Dec 2003 22:33:54 +0000 (22:33 +0000)
Wed Dec 17 23:31:19 2003  Kristian Rietveld  <kris@gtk.org>

* gtk/gtktreeview.c (gtk_tree_view_search_equal_func): only
try to strcmp or strlen if we managed to normalize and casefold
the string correctly. Fixes crashes with non-UTF8 strings.
(#121617, Patch from Tim-Philipp Müller).

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtktreeview.c

index 1489c7b5d3caa7bae9c2d93b6d948344d2b97633..eb21e70c267b2854bc540a81ddba684b69011894 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Dec 17 23:31:19 2003  Kristian Rietveld  <kris@gtk.org>
+
+       * gtk/gtktreeview.c (gtk_tree_view_search_equal_func): only
+       try to strcmp or strlen if we managed to normalize and casefold
+       the string correctly. Fixes crashes with non-UTF8 strings.
+       (#121617, Patch from Tim-Philipp Müller).
+
 Wed Dec 17 23:20:23 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkexpander.c (gtk_expander_animation_timeout): Add missing
index 1489c7b5d3caa7bae9c2d93b6d948344d2b97633..eb21e70c267b2854bc540a81ddba684b69011894 100644 (file)
@@ -1,3 +1,10 @@
+Wed Dec 17 23:31:19 2003  Kristian Rietveld  <kris@gtk.org>
+
+       * gtk/gtktreeview.c (gtk_tree_view_search_equal_func): only
+       try to strcmp or strlen if we managed to normalize and casefold
+       the string correctly. Fixes crashes with non-UTF8 strings.
+       (#121617, Patch from Tim-Philipp Müller).
+
 Wed Dec 17 23:20:23 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkexpander.c (gtk_expander_animation_timeout): Add missing
index 1489c7b5d3caa7bae9c2d93b6d948344d2b97633..eb21e70c267b2854bc540a81ddba684b69011894 100644 (file)
@@ -1,3 +1,10 @@
+Wed Dec 17 23:31:19 2003  Kristian Rietveld  <kris@gtk.org>
+
+       * gtk/gtktreeview.c (gtk_tree_view_search_equal_func): only
+       try to strcmp or strlen if we managed to normalize and casefold
+       the string correctly. Fixes crashes with non-UTF8 strings.
+       (#121617, Patch from Tim-Philipp Müller).
+
 Wed Dec 17 23:20:23 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkexpander.c (gtk_expander_animation_timeout): Add missing
index 1489c7b5d3caa7bae9c2d93b6d948344d2b97633..eb21e70c267b2854bc540a81ddba684b69011894 100644 (file)
@@ -1,3 +1,10 @@
+Wed Dec 17 23:31:19 2003  Kristian Rietveld  <kris@gtk.org>
+
+       * gtk/gtktreeview.c (gtk_tree_view_search_equal_func): only
+       try to strcmp or strlen if we managed to normalize and casefold
+       the string correctly. Fixes crashes with non-UTF8 strings.
+       (#121617, Patch from Tim-Philipp Müller).
+
 Wed Dec 17 23:20:23 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkexpander.c (gtk_expander_animation_timeout): Add missing
index 1489c7b5d3caa7bae9c2d93b6d948344d2b97633..eb21e70c267b2854bc540a81ddba684b69011894 100644 (file)
@@ -1,3 +1,10 @@
+Wed Dec 17 23:31:19 2003  Kristian Rietveld  <kris@gtk.org>
+
+       * gtk/gtktreeview.c (gtk_tree_view_search_equal_func): only
+       try to strcmp or strlen if we managed to normalize and casefold
+       the string correctly. Fixes crashes with non-UTF8 strings.
+       (#121617, Patch from Tim-Philipp Müller).
+
 Wed Dec 17 23:20:23 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkexpander.c (gtk_expander_animation_timeout): Add missing
index ee5ee4128a3dcf9e20879505466237c7af2dc9f4..cfd58f4c9ca52ffe62bb0f72cb03a8229052e8d8 100644 (file)
@@ -11608,8 +11608,8 @@ gtk_tree_view_search_equal_func (GtkTreeModel *model,
   gboolean retval = TRUE;
   gchar *normalized_string;
   gchar *normalized_key;
-  gchar *case_normalized_string;
-  gchar *case_normalized_key;
+  gchar *case_normalized_string = NULL;
+  gchar *case_normalized_key = NULL;
   GValue value = {0,};
   GValue transformed = {0,};
   gint key_len;
@@ -11628,12 +11628,18 @@ gtk_tree_view_search_equal_func (GtkTreeModel *model,
 
   normalized_string = g_utf8_normalize (g_value_get_string (&transformed), -1, G_NORMALIZE_ALL);
   normalized_key = g_utf8_normalize (key, -1, G_NORMALIZE_ALL);
-  case_normalized_string = g_utf8_casefold (normalized_string, -1);
-  case_normalized_key = g_utf8_casefold (normalized_key, -1);
 
-  key_len = strlen (case_normalized_key);
+  if (normalized_string && normalized_key)
+    {
+      case_normalized_string = g_utf8_casefold (normalized_string, -1);
+      case_normalized_key = g_utf8_casefold (normalized_key, -1);
+
+      key_len = strlen (case_normalized_key);
 
-  if (!strncmp (case_normalized_key, case_normalized_string, key_len))
+      if (!strncmp (case_normalized_key, case_normalized_string, key_len))
+        retval = FALSE;
+    }
+  else
     retval = FALSE;
 
   g_value_unset (&transformed);